import { getRoleIdsByUserId, showRoles } from "../service/role";

export default {
    namespaced:true,
    state:{
       roles:[],
       roleIds:[]
    },
    mutations:{
       setRoles(state,roles){
            state.roles = roles;
       },
       setRoleIds(state,roleIds){
            state.roleIds = roleIds;
       }
    },
    actions:{
       async setRoles({commit}){
            let response = await showRoles();
            commit('setRoles',response.data);
       },
       async setRoleIds({commit},userId){
            let response = await getRoleIdsByUserId(userId);
            commit('setRoleIds',response.data);
        }
    }
}